<template>
	<view class="box">
		<scroll-view style="height:100vh;padding: 40rpx;" scroll-y="true" @scrolltolower="loadMore">
			<view>
			</view>
			<u-loadmore :status="status" :load-text="loadText" bg-color="#f5f5f5" margin-top="20" margin-bottom="20" />
		</scroll-view>
	</view>
</template>

<script>
	const App = getApp().globalData
	import {
		getList
	} from '@/utils/api/visits.js'
	export default {
		data() {
			return {
				page: {
					current: 1,
					size: 10
				},
				query: {},
				navH: '',
				list: [],
				status: 'loadmore',
				loadText: {
					loadmore: '上拉加载更多',
					loading: '努力加载中',
					nomore: '没有更多了'
				}
			}
		},
		onShow() {
			// this.getList()
		},
		methods: {
			init() {
				this.page.current = 1
				this.getList()
			},
			getList() {
				this.status = 'loading'
				getList({
					...this.page,
				}).then(res => {
					console.log('res', res)
					this.list = this.list.concat(res.data.records)
					if (res.data.records.length < 10) {
						this.status = 'nomore'
					} else {
						this.status = 'loadmore'
					}
				})
			},
			loadMore() {
				if (this.status == 'nomore') {
					return
				}
				this.page.current = this.page.current + 1
				this.getList()
			},
		}
	}
</script>

<style scoped lang="scss">
	.box {
		min-height: 100vh;
		background-color: #f5f6f9;
	}
</style>
